﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web;
    using WMS6.Web.BillingServiceRef;

    public class BillingServiceClientProxy : BasePage
    {
        public string DeleteAccessorialCharges(List<string> IDS)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.DeleteAccessorialCharges(IDS, pubParasInfo);
            }
        }

        public string DeleteStatement(List<string> IDS)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.DeleteStatement(IDS, pubParasInfo);
            }
        }

        public string DeleteStatementDetail(string StatementID, List<string> LineID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.DeleteStatementDetail(StatementID, LineID, pubParasInfo);
            }
        }

        public AccessorialChargesOrderInfo GetAccessorialChargesByID(string orderID, string accessorialType)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.GetAccessorialChargesByID(orderID, accessorialType, pubParasInfo);
            }
        }

        public DataSet GetAccessorialChargesByQueryList(AccessorialChargesQueryEntity accessorialChargesQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.GetAccessorialChargesByQueryList(accessorialChargesQueryEntity, pubParasInfo);
            }
        }

        public static BillingServiceClientProxy GetInstance()
        {
            return new BillingServiceClientProxy();
        }

        public InvoiceInfo GetInvoiceByID(string InvoiceID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.GetInvoiceByID(InvoiceID, pubParasInfo);
            }
        }

        public DataSet GetInvoiceByQueryList(InvoiceQueryEntity invoiceQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.GetInvoiceByQueryList(invoiceQueryEntity, pubParasInfo);
            }
        }

        public StatementInfo GetStatementByID(string orderID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.GetStatementByID(orderID, pubParasInfo);
            }
        }

        public DataSet GetStatementByQueryList(StatementQueryEntity statementQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.GetStatementByQueryList(statementQueryEntity, pubParasInfo);
            }
        }

        public StatementDetailInfo GetStatementDetailInfoByID(string StatementID, string LineID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.GetStatementDetailInfoByID(StatementID, LineID, pubParasInfo);
            }
        }

        private PubParasInfo InitPubParasInfo()
        {
            if (base.UserInfo != null)
            {
                return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
            }
            HttpContext.Current.Response.Redirect("../Login.aspx?from=Logout", true);
            return null;
        }

        public string InsertAccessorialCharges(AccessorialChargesInfo accessorialChargesInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.InsertAccessorialCharges(accessorialChargesInfo, pubParasInfo);
            }
        }

        public string InsertInvoice(InvoiceInfo invoiceInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.InsertInvoice(invoiceInfo, pubParasInfo);
            }
        }

        public string InsertStatement(StatementInfo StatementInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.InsertStatement(StatementInfo, pubParasInfo);
            }
        }

        public string UpdateStatement(StatementInfo StatementInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.UpdateStatement(StatementInfo, pubParasInfo);
            }
        }

        public string UpdateStatementDetailReceived(StatementDetailInfo statementDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (BillingServiceClient client = new BillingServiceClient("WSHttpBinding_IBillingService"))
            {
                return client.UpdateStatementDetailReceived(statementDetailInfo, pubParasInfo);
            }
        }
    }
}

